#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <left4dhooks>



#define PLUGIN_NAME                   "l4d2_Player_Ghost_NoClip"    //这里写插件名字
#define PLUGIN_AUTHOR                 "豆瓣酱な"                         //作者
#define PLUGIN_DESCRIPTION            "特感鬼魂状态可以穿墙"   //介绍
#define PLUGIN_VERSION                "1.0"
#define PLUGIN_URL                    "https://gitee.com/sweet-and-sour-bombs"  //网站

public Plugin myinfo =
{
    name        = PLUGIN_NAME,
    author      = PLUGIN_AUTHOR,
    description = PLUGIN_DESCRIPTION,
    version     = PLUGIN_VERSION,
    url         = PLUGIN_URL
}


bool IsInfected(int client)
{
	return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 3;
}



public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
	if (IsInfected(client) &&  !IsFakeClient(client)  &&  IsPlayerGhost(client))
	{
		SetEntityMoveType(client, MOVETYPE_NOCLIP);
	}
	
	else if(IsInfected(client) &&  !IsFakeClient(client)  &&  !IsPlayerGhost(client))
	{
		SetEntityMoveType(client, MOVETYPE_WALK);	
	}
	return Plugin_Continue;
}


stock bool IsPlayerGhost(int client)
{
	return (GetEntProp(client, Prop_Send, "m_isGhost", 1) > 0);
}

